import { asyncRoutes, constantRoutes } from '@/router/index.js'

const state = {
  routes: []
}
const mutations = {
  setRoutes(state, data) {
    state.routes = [...constantRoutes, ...data]
  }
}
const actions = {
  filterRoutes(store, menus) {
    // console.log(menus)
    const routes = asyncRoutes.filter(el => menus.includes(el.name))
    // console.log(routes)
    store.commit('setRoutes', routes)

    return routes
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
